#ifndef PALETTE_H
#define PALETTE_H

#include <QWidget>
#include "colorcw.h"

class Palette : public QWidget
{
Q_OBJECT
	friend class ColorSelector;

public:
	enum paletteType {Brush, Layer};
	Palette(paletteType t, QWidget* parent = 0, Qt::WindowFlags f = 0);
	~Palette();

	void block();
	void unblock();

	paletteType getType() { return m_type; }

public slots:
	void setColorMap(ColorCW::ColorMap* colorMap, quint16 cmCnt);

signals:
	void currItemChanged(quint16 c);

protected:
	void paintEvent(QPaintEvent* /*event*/);
	void mousePressEvent(QMouseEvent* event);

	void updatePixmap(quint16 c);

private:
	QPixmap pixmap;
	ColorCW::ColorMap* m_colorMap;
	quint16 m_cmCnt;
	paletteType m_type;
	quint16 shiftY;
	quint8 shiftCol;
	bool blocked;
};

#endif // PALETTE_H
